using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class ProductVariantAttributeCombinationMap : EntityTypeConfiguration<ProductVariantAttributeCombination>
    {
        public ProductVariantAttributeCombinationMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Sku)
                .HasMaxLength(400);

            this.Property(t => t.ManufacturerPartNumber)
                .HasMaxLength(400);

            this.Property(t => t.Gtin)
                .HasMaxLength(400);

            // Table & Column Mappings
            this.ToTable("ProductVariantAttributeCombination");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ProductId).HasColumnName("ProductId");
            this.Property(t => t.AttributesXml).HasColumnName("AttributesXml");
            this.Property(t => t.StockQuantity).HasColumnName("StockQuantity");
            this.Property(t => t.AllowOutOfStockOrders).HasColumnName("AllowOutOfStockOrders");
            this.Property(t => t.Sku).HasColumnName("Sku");
            this.Property(t => t.ManufacturerPartNumber).HasColumnName("ManufacturerPartNumber");
            this.Property(t => t.Gtin).HasColumnName("Gtin");
            this.Property(t => t.OverriddenPrice).HasColumnName("OverriddenPrice");

            // Relationships
            this.HasRequired(t => t.Product)
                .WithMany(t => t.ProductVariantAttributeCombinations)
                .HasForeignKey(d => d.ProductId);

        }
    }
}
